package com.tqfframe.task.learning.extendStudy;

import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;

/**
 * @Author: 唐祺峰
 * @Date: 2020/8/28 0028 17:31
 * @Version 1.0
 */
@Data
@NoArgsConstructor
@RequiredArgsConstructor
public class ParentData {
    /**
     * 父类类型，page，view
     */
    @NonNull
    private String type;
    /**
     * 父类值
     */
    private String value;

    /**
     * 父类对象
     */
    private ParentData parentData;


    public String getValueByType(){
        if(type.equals("page")){
            return "我是父类page返回的值："+value;
        }
        return parentData==null?"":parentData.getValueByType();
    }

    public void setValueByType(String value){
        if(type.equals("page")){
            this.value=value;
        }else{
            if(parentData!=null){
                parentData.setValueByType(value);
            }
        }

    }
}